<!DOCTYPE html>
<html>
<head>
  <link rel="chrome-webstore-item">
</head>
<body>
<script>
if (window.location.search == "") {
  window.open(window.location.href + "?install", "w", "toolbar=no");
} else {
  document.title = "POPUP";
}

function runTest(galleryUrl) {
  // Link URL has to be generated dynamically in order to include the right
  // port number. The ID corresponds to the data in the "extension" directory.
  document.getElementsByTagName('link')[0].href =
      galleryUrl + '/detail/ecglahbcnmdpdciemllbhojghbkagdje';

  try {
    chrome.webstore.install(
        undefined,
        function() {
          console.error('Did not expect install complete in a pop-up window.');
          window.domAutomationController.send(false);
        },
        function(error) {
          var expected_error =
              "Inline installs can not be initiated from pop-up windows.";
          window.domAutomationController.send(error == expected_error);
        }
    );
  } catch (e) {
    console.error('Unexpected exception: ', e);
    window.domAutomationController.send(false);
    throw e;
  }
}
</script>

</body>
</html>
